package com.itboye.ihomebank.util;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.ihomebank.R;

/**
 * Created by Itboye-000018 on 2017/12/21.
 */
public class LoadingDialogTwo extends Dialog {
    private TextView tv_text;
    ImageView pro_img;
    public LoadingDialogTwo(Context context) {
        super(context);
        /**设置对话框背景透明*/
        getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        setContentView(R.layout.loading_dialog_view);
        pro_img = (ImageView) findViewById(R.id.pro_img);
        // 加载动画
        Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(
                context, R.anim.loading_animation);
        // 使用ImageView显示动画
        pro_img.startAnimation(hyperspaceJumpAnimation);

        tv_text = (TextView) findViewById(R.id.tv_text);
        setCanceledOnTouchOutside(false);
    }
    /**
     * 为加载进度个对话框设置不同的提示消息
     * @param message 给用户展示的提示信息
     * @return build模式设计，可以链式调用
     */
    public LoadingDialogTwo setMessage(String message) {
        tv_text.setText(message);
        return this;
    }
}
